package cn.com.huzo.repository.trade.impl;

import cn.com.huzo.model.entities.trade.ShippingOrderLinesEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.List;
import org.springframework.stereotype.Repository;
import cn.com.huzo.repository.trade.ShippingOrderLinesRepository;
import java.util.HashMap;
import java.util.Map;

/**
 * 发货发令单明细数据访问对象。
 *
 * @author 吴旭
 */
@Repository("ShippingOrderLinesRepository")
public class ShippingOrderLinesRepositoryImpl extends GenericRepositoryImpl<ShippingOrderLinesEntity, String>
        implements ShippingOrderLinesRepository {

    private final String namespace = "cn.com.huzo.repository.trade.ShippingOrderLinesRepository";

    /**
     * 构造函数,设置the entity to ShipOrderHeaderRepositoryImpl.class.
     */
    public ShippingOrderLinesRepositoryImpl() {
        super(ShippingOrderLinesEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<ShippingOrderLinesEntity> fetchByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<Map<String, Object>> fetchCartonAmount(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchCartonAmount"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> criterion) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<ShippingOrderLinesEntity> fetchForPage(Map<String, Object> criterion) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void caclCartonNo(Long headerId, Boolean assortedColourFlag, Boolean assortedSizeFlag,
            Boolean newNoPerDestinationFlag, Boolean newNoPerColourFlag) {
        Map<String, Object> _params = new HashMap();
        _params.put("HeaderId", headerId);
        _params.put("AssortedColourFlag", assortedColourFlag);
        _params.put("AssortedSizeFlag", assortedSizeFlag);
        _params.put("NewNoPerDestinationFlag", newNoPerDestinationFlag);
        _params.put("NewNoPerColourFlag", newNoPerColourFlag);

        getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "caclCartonNo"), _params);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchInsert(List<ShippingOrderLinesEntity> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchInsert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchUpdate(List<ShippingOrderLinesEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchUpdate"), itemList);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public Integer deleteByHeaderId(Long headerId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public Integer delete(String linesId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), linesId);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public List<String> fetchSizeNameNode(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchSizeNameNode"), headerId);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public List<ShippingOrderLinesEntity> fetchPrintData(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchPrintData"), headerId);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public List<ShippingOrderLinesEntity> fetchPrintData02(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchPrintData02"), headerId);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public List<ShippingOrderLinesEntity> fetchPrintData03(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchPrintData03"), headerId);
    }

    /**
     * {@inheritDoc}
     * <p>
     */
    @Override
    public List<ShippingOrderLinesEntity> fetchLinesDesc(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchLinesDesc"), headerId);
    }
}
